home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / incl / LEDA / impl / delaunay_tree.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  5.5 KB  |  226 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  delaunay_tree.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_DELAUNAY_H
  16. #define LEDA_DELAUNAY_H
  17.  
  18. /*****************************************************************************
  19. +
  20. +    Delaunay tree    by Olivier Devillers
  21. +
  22. +        Fully dynamic construction of the Delaunay triangulation with
  23. +        good randomized complexity
  24. +
  25. +    Copyright (c) 1990
  26. +    INRIA, 2004 route des Lucioles, 06 565 Valbonne Cedex, France
  27. +
  28. +    for LEDA
  29. +    Copyright (c) 1990  by  Max Planck Institut f"ur Informatik
  30. +    Im Stadtwald, 6600 Saarbruecken, FRG
  31. +     All rights reserved.
  32. +
  33. ******************************************************************************/
  34.  
  35. #include <LEDA/point.h>
  36.  
  37. typedef double coord;
  38.  
  39. struct NOEUD;
  40. typedef NOEUD* noeud;
  41.  
  42. struct STAR;
  43. typedef STAR* star;
  44.  
  45. struct REINSERER;
  46. typedef REINSERER* reinserer;
  47.  
  48. struct LISTENOEUD;
  49. typedef LISTENOEUD* listenoeud;
  50.  
  51.  
  52. struct DT_POINT{
  53.     coord x,y;
  54.         void* i;
  55.     int  n;                   /* un flag dont l'ordre est compatible avec
  56.                           l'ordre d'insertion */
  57.     int  visite;           /* un flag de visite */
  58.     NOEUD* cree;    /*un noeud cree par l'insertion de ce point*/
  59. }; 
  60.  
  61. typedef DT_POINT* DT_item;
  62.  
  63.  
  64.  
  65. typedef void delaunay_f2(double,double);
  66. typedef void delaunay_f4(double,double,double,double);
  67. typedef void delaunay_f6(double,double,double,double,double,double);
  68. typedef void delaunay_F6(double,double,double,double,double*,double*);
  69.  
  70.  
  71.  
  72. class delaunay_tree{
  73.  
  74.         int flag;        /* numero de l'operation en cours */
  75.         noeud nouveau;        /* dernier noeud cree */
  76.         
  77.         star Star;        /* pour la suppression */
  78.         reinserer Reinsert;
  79.  
  80.     NOEUD * arbre ;        /* la racinne du Delaunay tree */
  81.     NOEUD * last ;        /* dernier noeud cree */
  82.  
  83.         int counter;            /* total number of items (s.n.) */
  84.  
  85.  
  86.  
  87. char*      used_blocks;
  88. DT_item    Poubelle_point;
  89. listenoeud Poubelle_listenoeud;
  90. noeud      Poubelle_noeud;
  91. noeud      Libre_noeud;
  92. star       Poubelle_star;
  93. reinserer  Poubelle_reinserer;
  94.  
  95. int fl;
  96.  
  97. int item_nombre;
  98. DT_item item_next;
  99.  
  100. int listenoeud_nombre;
  101. listenoeud listenoeud_next;
  102.  
  103. int noeud_nombre;
  104. noeud noeud_next;
  105.  
  106. int star_nombre;
  107. star star_next;
  108.  
  109. int reinserer_nombre;
  110. reinserer reinserer_next;
  111.  
  112. star first_star;
  113.  
  114.  
  115.  
  116. char*      alloc_block(int size);
  117. void       free_blocks();
  118. void       poubelle_point(DT_item p);
  119. DT_item    vrai_alloc_point();
  120. DT_item    alloc_point();
  121. void       poubelle_listenoeud(listenoeud p);
  122. listenoeud vrai_alloc_listenoeud();
  123. listenoeud alloc_listenoeud();
  124. void       poubelle_noeud(noeud p);
  125. noeud      vrai_alloc_noeud();
  126. noeud      alloc_noeud();
  127. void       poubelle_star(star p);
  128. star       vrai_alloc_star();
  129. star       alloc_star();
  130. void       poubelle_reinserer( reinserer p);
  131. reinserer  vrai_alloc_reinserer();
  132. reinserer  alloc_reinserer();
  133.  
  134. void  beaufils( noeud bf, noeud bp);
  135. void  plusbeaufils( noeud bf, noeud bp);
  136. void  demiplan( noeud t);
  137. void  cercle( noeud t);
  138. int   confondu( DT_item a, DT_item b);
  139. int   direct( noeud n);
  140. int   conflit( noeud n, DT_item p);
  141. noeud Insert( noeud n, DT_item p);
  142. noeud creenoeud( noeud pere, int i, DT_item p);
  143. int   creation( noeud detruit, DT_item p);
  144. DT_item localise( noeud detecte, DT_item p);
  145. void  add_x1x2( reinserer r, noeud v, DT_item p);
  146. void  add_decroche( reinserer r, noeud v);
  147. void  destroy( noeud u, DT_item p);
  148. void  recherche( DT_item p);
  149. void  reinsertion( reinserer n, DT_item p);
  150. void  parcours( reinserer n, DT_item p);
  151. void  trace_items(noeud, delaunay_f2*);
  152. void  list_items(noeud n, list<DT_item>& L);
  153. void  clear_items(noeud n);
  154. void  del_noeud( noeud n, delaunay_f4* trace_segment,int both);
  155. void  vor( noeud n, delaunay_f6* trace_segment, delaunay_F6* pt_infi, int both);
  156.  
  157. virtual void copy_inf(GenPtr& p)  { p=p; }
  158. virtual void clear_inf(GenPtr& p) { p=0; }
  159.  
  160. public:
  161.  
  162. delaunay_tree();
  163. virtual ~delaunay_tree();
  164.  
  165. reinserer locate( reinserer n, DT_item x);
  166. void clear_Reinsert( reinserer n);
  167. void clear_Star();
  168. void init_Star( noeud n, int i, int j, int k);
  169. star loc_Star( DT_item xx);
  170. void split_Star( star n1,star n2);
  171.  
  172. DT_item insert(double, double, void*);
  173.  
  174. DT_item insert(point p, void* inf) { return insert(p.xcoord(),p.ycoord(),inf); }
  175.  
  176. DT_item neighbor(double, double);
  177. DT_item neighbor(point p)          { return neighbor(p.xcoord(),p.ycoord()); }
  178. void    del(double, double);
  179. void    del(point p)               { del(p.xcoord(),p.ycoord()); }
  180. void    del_item( DT_item);
  181.  
  182. point    key(DT_item p)  { return point(p->x,p->y); } 
  183. void*    inf(DT_item p)  { return p->i; } 
  184.  
  185. void     change_inf(DT_item p, void* i)  { copy_inf(i);  
  186.                                            clear_inf(p->i); 
  187.                                            p->i = i; } 
  188.  
  189. void     trace_voronoi_sites( delaunay_f2*);
  190. void     trace_voronoi_edges( delaunay_f6*, delaunay_F6*, int both = 0);
  191. void     trace_triang_edges( delaunay_f4* , int both = 0);
  192.  
  193. void     all_items(list<DT_item>&);
  194.  
  195. void     convex_hull(list<DT_item>&);
  196.  
  197. void     clear();
  198. void     init();
  199.  
  200. };
  201.  
  202.  
  203.  
  204.  
  205. template<class itype>
  206.  
  207. class _CLASSTYPE DELAUNAY_TREE : public delaunay_tree {
  208.  
  209. void copy_inf(GenPtr& p)  { Copy(*(itype*)&p); }
  210. void clear_inf(GenPtr& p) { Clear(*(itype*)&p); }
  211.  
  212. public:
  213.  
  214. DT_item insert(point site, itype i)
  215.                           { return delaunay_tree::insert(site,Convert(i)); }
  216.  
  217. itype  inf(DT_item p)    { return itype(delaunay_tree::inf(p)); } 
  218.  
  219.  DELAUNAY_TREE() {}
  220. ~DELAUNAY_TREE() {}
  221.  
  222. };
  223.  
  224. #endif
  225.